package com.singzi.leetcode.N1200;

public class T1185 {
    public static void main(String[] args) {
        Solution1185 solution1185 = new Solution1185();
        System.out.println(solution1185.dayOfTheWeek(3, 1, 2022));
    }


}
class Solution1185 {
    public String dayOfTheWeek(int day, int month, int year) {
        String [] week = {"Friday", "Saturday","Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"};
        int[] months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int sum = 0;
        for (int i = 1971; i < year; i++) {
            if(isLeapYear(i)) sum +=366;
            else sum+=365;
        }
        if(month>2&&isLeapYear(year)) months[1] += 1;
        for (int i = 0; i < month-1; i++) {
            sum += months[i];
        }
        sum += day;
        return week[(sum-1)%7];
    }
    public boolean isLeapYear(int year){
        return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
    }
}